<?php

include 'confidential_settings.php';
// This include contains 5 variables:
//  - db_name: database name
//  - table_name_x: table name
//  - username: username
//  - password: password
//  - localhost: host name


// === Get cum day value ===
/*
$cum_val  = 0;
$dbh=mysql_connect ($localhost, $username, $password) or die('Cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_name) or die(mysql_error()); 
$result = mysql_query("SELECT SUM(val) AS sum_val FROM $table_name_gsc WHERE CURDATE() == DATE(date_entered)");
mysql_close($dbh);
mysql_data_seek ($result , 0);
if($row = mysql_fetch_array($result)){
	$cum_val = $row['sum_val'];
}
*/

// === Add to database ===
$dbh=mysql_connect ($localhost, $username, $password) or die('Cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_name) or die(mysql_error()); 
$val = $_GET['val'];
$tmp_val = $val;
$val = mysql_real_escape_string($val);
mysql_query("INSERT INTO $table_name_gsc
(val) VALUES($val) ") or die(mysql_error());  
mysql_close($dbh);

// Send response
//echo $cum_val;
echo "[OK]";

?>


